import {fetch, fetchCPT} from './fetch.js';

const POST = 'post';
const GET = 'get';
// const DELETE = 'delete';
// const PUT = 'put';

const apiList = {
    // 登录
    login: function (params) {
        return fetchCPT({
            url: '/Login',
            method: 'post',
            data: params
        });
    },
    // 验证码
    getCpt: function (params) {
        return fetchCPT({
            url: '/Getcpt',
            method: 'get',
            data: params
        });
    },
    // 退出
    logout: function (params) {
        return fetch({
            url: '/auth/LogoutAPI',
            method: 'get',
            params: params
        });
    },
    Loginynz: function (params) {
        return fetchCPT({
            url: '/Loginynz',
            method: POST,
            data: params
        });
    },
    // 获取用户数据
    getMe: function (params) {
        return fetch({
            url: '/user/Getme',
            method: 'get',
            params: params
        });
    },
    // 获取资源
    getResource: function (params) {
        return fetch({
            url: '/resource/',
            method: 'get',
            params: params
        });
    },
    // 更新资源
    updateResource: function (data) {
        return fetch({
            url: '/resource/Update',
            method: 'post',
            params: data
        });
    },
    // 添加资源
    addResource: function (data) {
        return fetch({
            url: '/resource/',
            method: 'post',
            params: data
        });
    },
    // 删除资源
    deleteResource: function (data) {
        return fetch({
            url: '/resource/Delete',
            method: 'post',
            params: data
        });
    },
    // 获取用户列表
    getUser: function (data) {
        return fetch({
            url: '/user/',
            method: 'get',
            params: data
        });
    },
    GetUserByDept: function (data) {
        return fetch({
            url: '/user/GetUserByDept',
            method: 'post',
            params: data
        });
    },
    // 获取单位用户列表
    GetAllOrgUsers: function (data) {
        return fetch({
            url: '/user/GerUserByOrg',
            method: 'get',
            params: data
        });
    },
    QueryUsersByOrgAndRole: (data) => {
        return fetch({
            url: '/user/QueryUsersByOrgAndRole',
            method: POST,
            params: data
        });
    },
    // 根据角色获取单位用户
    GetUsersByRole: function (data) {
        return fetch({
            url: '/user/GetAllOrgUsers',
            method: 'get',
            params: data
        });
    },
    // 更新用户
    updateUser: function (data) {
        return fetch({
            url: '/user/Update',
            method: 'post',
            params: data
        });
    },
    // 添加用户
    addUser: function (data) {
        return fetch({
            url: '/user/',
            method: 'post',
            params: data
        });
    },
    // 删除用户
    deleteUser: function (data) {
        return fetch({
            url: '/user/Delete',
            method: 'post',
            params: data
        });
    },
    // 删除用户列表
    deleteUsers: function (data) {
        return fetch({
            url: '/user/DeleteUsers',
            method: 'post',
            params: data
        });
    },
    QueryUsersByRoleNameAndDept: (data) => {
        return fetch({
            url: '/user/QueryUsersByRoleNameAndDept',
            method: POST,
            params: data
        });
    },
    GetUserById: (data) => {
        return fetch({
            url: `/user/${data}`,
            method: GET
        });
    },
    // 更新密码
    ChangePwd: function (data) {
        return fetch({
            url: '/user/ChangePwd',
            method: 'post',
            params: data
        });
    },
    // 重置密码
    ResetPwd: function (data) {
        return fetch({
            url: '/user/ResetPwd',
            method: 'post',
            params: data
        });
    },
    // 更新用户属性
    UpdateUserProf: function (data) {
        return fetch({
            url: '/user/UpdateUserProf',
            method: 'post',
            params: data
        });
    },
    // 照片取消
    PhotoCancel: function (data) {
        return fetch({
            url: '/user/PhotoCancel',
            method: 'post',
            params: data
        });
    },
    // 获取客户单位
    getOrganization: function (data) {
        return fetch({
            url: '/organization/',
            method: 'get',
            params: data
        });
    },
    // 获取客户单位列表
    getOrganizationList: function (data) {
        return fetch({
            url: '/organization/GetOrganizationList',
            method: 'get',
            params: data
        });
    },
    // 更新客户单位
    updateOrganization: function (data) {
        return fetch({
            url: '/organization/Update',
            method: 'post',
            params: data
        });
    },
    // 添加客户单位
    addOrganization: function (data) {
        return fetch({
            url: '/organization/',
            method: 'post',
            params: data
        });
    },
    // 删除客户单位列表
    deleteOrganization: function (data) {
        return fetch({
            url: '/organization/Delete',
            method: 'post',
            params: data
        });
    },
    // 获取角色
    getRole: function (data) {
        return fetch({
            url: '/role/',
            method: 'get',
            params: data
        });
    },
    // 获取管理员以外的角色
    QueryRolesExclusiveSystem() {
        return fetch({
            url: '/role/QueryRolesExclusiveSystem',
            method: GET
        });
    },
    // 获取角色列表
    getRoleList: function (data) {
        return fetch({
            url: '/role/GetRoleList',
            method: 'get',
            params: data
        });
    },
    // 获取组织角色列表
    GetOrgRoleList: function (data) {
        return fetch({
            url: '/role/GetOrgRoleList',
            method: 'get',
            params: data
        });
    },
    // 更新角色
    updateRole: function (data) {
        return fetch({
            url: '/role/Update',
            method: 'post',
            params: data
        });
    },
    // 添加角色
    addRole: function (data) {
        return fetch({
            url: '/role/',
            method: 'post',
            params: data
        });
    },
    // 删除角色
    deleteRole: function (data) {
        return fetch({
            url: '/role/Delete',
            method: 'post',
            params: data
        });
    },
    // 删除多个角色
    deleteRoles: function (data) {
        return fetch({
            url: '/role/DeleteRoles',
            method: 'post',
            params: data
        });
    },
    // 获取角色资源树
    GetRoleResourceTree: function (data) {
        return fetch({
            url: `/role/GetRoleResourceTree/` + data,
            method: 'get'
        });
    },
    // 获取角色资源树2
    GetResByRole: function (data) {
        return fetch({
            url: `/role/GetResByRole/` + data,
            method: 'get'
        });
    },

    // 角色分配资源
    AssignResources: function (data) {
        return fetch({
            url: '/role/AssignResources',
            method: 'post',
            params: data
        });
    },
    // 获取部门
    GetDept: function (data) {
        return fetch({
            url: '/dept/',
            method: 'get',
            params: data
        });
    },
    GetDeptTree: function () {
        return fetch({
            url: '/dept/GetDeptTree',
            method: 'get'
        });
    },
    SetDeptDirector: function (data) {
        return fetch({
            url: '/dept/SetDeptDirector',
            method: 'post',
            params: data
        });
    },
    // 更新部门
    UpdateDept: function (data) {
        return fetch({
            url: '/dept/Update',
            method: 'post',
            params: data
        });
    },
    // 添加部门
    AddDept: function (data) {
        return fetch({
            url: '/dept/',
            method: 'post',
            params: data
        });
    },
    // 删除部门
    DeleteDept: function (data) {
        return fetch({
            url: '/dept/Delete',
            method: 'post',
            params: data
        });
    },
    // 删除部门列表
    DeleteDepts: function (data) {
        return fetch({
            url: '/dept/DeleteDepts',
            method: 'post',
            params: data
        });
    },
    // 用户分配部门
    AssignUserDept: function (data) {
        return fetch({
            url: '/dept/AssignUserDept',
            method: 'post',
            params: data
        });
    },
    GetEngineerByDept: function (data) {
        return fetch({
            url: '/engineer/GetEngineerByDept',
            method: 'post',
            params: data
        });
    },
    // -----------------------------------------------------权限模块------------------------------------------------
    /**
     * GetModules
     * 获取角色模块
     */
    GetModules: () => {
        return fetch({
            url: '/resource/GetModules',
            method: 'get'
        });
    },
    GetMenus: (data) => {
        return fetch({
            url: '/resource/GetMenus',
            method: 'post',
            params: data
        });
    },
    GetOperateLabels: (data) => {
        return fetch({
            url: '/resource/GetOperateLabels',
            method: 'post',
            params: data
        });
    },
    GetAllResouce2: () => {
        return fetch({
            url: '/resource/resouce2',
            method: 'get'
        });
    },
    AddResouce2: (data) => {
        return fetch({
            url: '/resource/AddResouce2',
            method: 'post',
            params: data
        });
    },
    UpdateResouce2: (data) => {
        return fetch({
            url: '/resource/UpdateResouce2',
            method: 'post',
            params: data
        });
    },
    DeleteResouce2s: (data) => {
        return fetch({
            url: '/resource/DeleteResouce2s',
            method: 'post',
            params: data
        });
    },

    // 获取日志
    getLog: function (data) {
        return fetch({
            url: '/log/GetAll',
            method: 'post',
            params: data
        });
    },
    // 删除日志
    deleteLogs: function (data) {
        return fetch({
            url: '/log/DeleteLogs',
            method: 'post',
            params: data
        });
    },

    // 区域管理
    getAllRegion: (data) => {
        return fetch({
            url: '/region/GetAll',
            method: POST,
            params: data
        })
    },
    getOneRegion: (id) => {
        if (id.length> 0) {
            return fetch({
                url: `/region/${id}`,
                method: GET
            })
        }
    },
    addRegion: (data) => {
        return fetch({
            url: '/region',
            method: POST,
            params: data
        })
    },
    deleteRegion: (ids) => {
        return fetch({
            url: '/region/Delete',
            method: POST,
            params: ids
        })
    },
    updateRegion: (data) => {
        return fetch({
            url: '/region/Update',
            method: POST,
            params: data
        })
    },

    // param
    // 系统参数管理
    getAllParam: (data) => {
        return fetch({
            url: '/param/GetAll',
            method: POST,
            params: data
        })
    },
    getOneParam: (id) => {
        if (id.length> 0) {
            return fetch({
                url: `/param/${id}`,
                method: GET
            })
        }
    },
    addParam: (data) => {
        return fetch({
            url: '/param',
            method: POST,
            params: data
        })
    },
    deleteParam: (ids) => {
        return fetch({
            url: '/param/Delete',
            method: POST,
            params: ids
        })
    },
    updateParam: (data) => {
        return fetch({
            url: '/param/Update',
            method: POST,
            params: data
        })
    },

};

export default apiList;
